#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@his-pc>
#
# Distributed under terms of the MIT license.

"""

"""


class Solution:
    DIGIT = 33

    def hashCode(self, key, HASH_SIZE):
        hash_value = 0

        for i in key:
            # 关键点在于每次先hash, 供下次计算.
            hash_value = (hash_value * self.DIGIT + ord(i) ) % HASH_SIZE

        return hash_value


def main():
    print("start main")
    s = Solution()
    ret = s.hashCode('abcd', 100)
    print(ret)

if __name__ == "__main__":
    main()
